<template>
  <div>
        <van-nav-bar class="app-nav-bar" title="卫生检查列表" left-arrow @click-left="onClickLeft"/>
        <!-- <el-input type="date" style="width: 200px;" placeholder="请输入内容" clearable v-model="form.date"></el-input> -->
        <el-button size="mini" value-format="yyyy-MM-dd" class="btncolor" type="success" @click="ws">卫生检查录入</el-button>
        <van-cell>卫生检查日期：
            <el-date-picker type="date" placeholder="请选择卫生检查日期" v-model="checkDate"></el-date-picker>
            <el-button style="margin-left: 5px;" size="mini" type="primary" icon="el-icon-search" @click="getUser">搜索</el-button>
        </van-cell>
        <el-table
        :data="tableData"
        style="width: 100%">
        <el-table-column
            prop="id"
            label="序号" width="50px">
        </el-table-column>
        <el-table-column
            prop="checkDate"
            label="卫生检查日期" width="70px">
        </el-table-column>
        <el-table-column
            prop="dorAddress"
            label="宿舍" width="80px">
        </el-table-column>
        <el-table-column
            prop="totalPdeduct"
            label="总扣分">
        </el-table-column>
        <el-table-column
            prop="totalScore"
            label="总得分">
        </el-table-column>
        <el-table-column label="操作">
            <template slot-scope="scope">
                <el-button type="success" class="btncolor" size="mini" @click="xq(scope.row)">详情</el-button>
                <el-button size="mini" icon="el-icon-edit" @click="xg(scope.row)"></el-button>
                <el-button size="mini" icon="el-icon-delete" @click="del(scope.row)"></el-button>
            </template>
        </el-table-column>
        </el-table>

  </div>
</template>

<script>
import {Dialog} from 'vant'
export default {
data(){
        return{
            tableData:[],
            checkDate:"",
        }
    },
    methods:{
        onClickLeft(){
            this.$router.go(-1) 
        },
        ws(){
            this.$router.push({name: 'HygieneAdd', params: { id:2}})
        },
        xg(row){
             this.$router.push({name: 'HygieneEdit', params: { id: row.id}})
        },
        xq(row){
            this.$router.push({name: 'HygieneDetail', params: { id: row.id}})
        },
       del(row){
        Dialog.confirm({
            title: '提示',
            message: '确认删除？',
            })
            .then(async () => {
                var {data:res} = await this.request({
                    url:this.$location.deleteHygieneById,
                    params:{
                        id:row.id
                    }
                })
                console.log(res);
                if(res.status==200){
                    this.$toast.success(res.msg)
                    this.getUser();
                }else{
                    this.$toast.fail(res.msg)
                    this.getUser();
                }
            })
            .catch(() => {
            });
       },
        async getUser(){
            console.log(this.checkDate);
            const {data:res} =await this.request("app/Hygiene/getHygieneAll?checkDate="+this.checkDate);
            console.log(res)
            this.tableData=res.data
        },
    },created(){
        this.getUser();
    }
}
</script>

<style>
.el-table .cell {
    line-height: 23px !important;
    padding-right: 10px;
}
.el-table td.is-center, .el-table th.is-center {
    text-align: center !important;
}
</style>